//
//  UIBarButton+Extention.swift
//  SinaBlog
//
//  Created by macs on 15/11/19.
//  Copyright © 2015年 BlackTail. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    convenience init(imageName : String?,target : AnyObject?,actionName : String?) {
        let btn = UIButton(type: .Custom)
        btn.setImage( UIImage(named: imageName!), forState: .Normal)
        btn.setImage(UIImage(named: imageName! + "_highlighted" ), forState: .Highlighted)
        if actionName != nil {
            
           btn.addTarget(target, action:Selector(actionName!), forControlEvents: .TouchUpInside)
        }
        
        btn.sizeToFit()
        self.init(customView : btn)
    }
    
}
